<template>
  <div class="card" :style="'width:' + cardWidth +'px'"  @click="handleToChapter(dataList.id)">
    <el-card shadow="hover" v-if="dataList.id">
      <div class="item">
        <div class="detail">
          <div class="name">{{dataList.name}}</div>
          <div class="new">
            <div>{{dataList.writer}} 著</div>
            <div class="chapter" v-show="dataList.new_chapter">最新:{{dataList.new_chapter}}</div>
            <div class="intro" v-show="intro">简介:{{dataList.intro}}</div>
          </div>
          <div class="tag">
            <span>{{dataList.is_over}}</span>
            <span>{{dataList.type}}</span>
          </div>
        </div>
        <div class="img">
          <el-image :src="dataList.image" lazy>
            <div slot="error">
              <img src="http://foglake.sanye666.top/images/default-covor.jpg" alt />
            </div>
          </el-image>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "card",
  props: {
    dataList: Object,
    cardWidth: Number,
    intro: Boolean,
  },
  watch: {
    dataList(val) {
      this.dataList = val;
    },
  },
  methods: {
    handleToChapter(id) {
      this.$router.push({
        path: "/chapter",
        query: { id },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.card {
  width: 468px;
  margin-bottom: 20px;
  animation: fadeIn 1s;
  cursor: pointer;
  &:hover {
    transform: translateY(-3px);
    transition: all 0.3s linear;
  }
  .item {
    height: 240px;
    background: rgba(255, 255, 255, 1);
    border-radius: 12px;
    padding: 24px 24px 24px 33px;
    display: flex;
    justify-content: space-between;
    .detail {
      text-align: left;
      width: 60%;
      .name {
        height: 24px;
        font-size: 24px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(6, 27, 65, 0.65);
        line-height: 24px;
        margin-top: 16px;
        margin-bottom: 24px;
      }
      .new {
        height: 36px;
        font-size: 14px;
        font-family: MicrosoftYaHei;
        font-weight: 400;
        color: rgba(6, 27, 65, 0.45);
        line-height: 22px;
        margin-bottom: 43px;
        .chapter {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
        .intro {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
      }
      .tag {
        padding: 20px 0;
        width: 90%;
        border-top: 1px solid rgba(6, 27, 65, 0.05);
        span {
          font-size: 12px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          color: rgba(189, 141, 255, 1);
          line-height: 24px;
          border: 1px solid rgba(189, 141, 255, 1);
          border-radius: 14px;
          padding: 6px 13px 6px 14px;
          margin-right: 8px;
        }
        span:last-child {
          color: rgba(255, 130, 130, 1);
          border: 1px solid rgba(255, 130, 130, 1);
        }
      }
    }
    .img {
    }
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
</style>